home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Everything / CModalButtons.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  4.8 KB  |  221 lines  |  [TEXT/CWIE]

  1. // CModalButtons.cp -- dialog methods
  2.  
  3. #include "CModalButtons.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LStaticText.h>
  11. #include <LAMStaticTextImp.h>
  12. #include <LGAStaticTextImp.h>
  13. #include <CInvisibleButton.h>
  14. #include <LPushButton.h>
  15. #include <LAMPushButtonImp.h>
  16. #include <LGAPushButtonImp.h>
  17. #include <LTextGroupBox.h>
  18. #include <LAMControlViewImp.h>
  19. #include <LGATextGroupBoxImp.h>
  20. #include <LBevelButton.h>
  21. #include <LAMBevelButtonImp.h>
  22. #include <LGABevelButtonImp.h>
  23. #include <LCicnButton.h>
  24. #include <CustomControls.h>
  25. #include <LButton.h>
  26. #include <CTextUtils.h>
  27.  
  28. #include "EverythingCmds.h"
  29. #include <PP_Messages.h>
  30.  
  31.  
  32. #define PPob_ModalButtonsID    208
  33. #define RidL_ModalButtonsID    208
  34.  
  35. Boolean        CModalButtons::sIsRegistered = false;
  36.  
  37. //----------
  38. CModalButtons*        CModalButtons::CreateModalButtons (
  39.     LCommander*        inSuperCommander,
  40.     CommandT        inCommand)
  41. {
  42.     if (!sIsRegistered) {
  43.         RegisterClass ();
  44.     }
  45.     CModalButtons*        dlog;
  46.     dlog = ((CModalButtons *)LWindow::CreateWindow(PPob_ModalButtonsID, inSuperCommander));
  47.     dlog->mCommand = inCommand;
  48.  
  49.     return dlog;
  50. }
  51.  
  52. //----------
  53. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  54.     RegisterClass_(AbstractClass);    \
  55.     if (useAppearance) {    \
  56.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  57.     } else {    \
  58.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  59.     }
  60.  
  61. //----------
  62. void    CModalButtons::RegisterClass ()
  63. {
  64.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  65.  
  66.     RegisterClass_(CModalButtons);
  67.  
  68.     // register the pane classes we use
  69.     RegisterClasses (LStaticText, LAMStaticTextImp, LGAStaticTextImp);
  70.     RegisterClass_(CInvisibleButton);
  71.     RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
  72.     RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
  73.     RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
  74.     RegisterClass_(LCicnButton);
  75.     RegisterClasses (CPushButton, CustomControlImp, CustomControlImp);
  76.     RegisterClass_(LButton);
  77.  
  78.     sIsRegistered = true;
  79. }
  80.  
  81. //----------
  82. CModalButtons::CModalButtons (
  83.     LStream*    inStream)
  84.     : LGADialog (inStream)
  85. {
  86. }
  87.  
  88. //----------
  89. CModalButtons::~CModalButtons()
  90. {
  91. }
  92.  
  93. //----------
  94. //    This member function gets called once the containment hierarchy that contains
  95. //    this pane has been built. It gives us a chance to get data members for
  96. //    interesting subviews, and to do other operations now that our subviews exist.
  97. void    CModalButtons::FinishCreateSelf()
  98. {
  99.     LGADialog::FinishCreateSelf();
  100.  
  101.     mInvisibleButton = (CInvisibleButton*) FindPaneByID ('Inve');
  102.  
  103.     mStandardButton = (LPushButton*) FindPaneByID ('Stad');
  104.  
  105.     mDefaultButton = (LPushButton*) FindPaneByID ('Deft');
  106.  
  107.     mButtonButton = (LBevelButton*) FindPaneByID ('Butn');
  108.  
  109.     mNextButton = (LBevelButton*) FindPaneByID ('Next');
  110.  
  111.     mNext2Button = (LBevelButton*) FindPaneByID ('Nex2');
  112.  
  113.     mRightButton = (LCicnButton*) FindPaneByID ('Rigt');
  114.  
  115.     mLightButton = (CPushButton*) FindPaneByID ('Ligt');
  116.  
  117.     mRight2Button = (LButton*) FindPaneByID ('Rig2');
  118.  
  119.     mButton2Button = (CPushButton*) FindPaneByID ('But2');
  120.  
  121.     mRight3Button = (LButton*) FindPaneByID ('Rig3');
  122.  
  123.     mRect3DButton = (CPushButton*) FindPaneByID ('RecD');
  124.  
  125.     mLeftIconButton = (LPushButton*) FindPaneByID ('Lefn');
  126.  
  127.     mRightIconButton = (LPushButton*) FindPaneByID ('Rign');
  128.  
  129.     mTitledPICTButton = (CPushButton*) FindPaneByID ('TitT');
  130.  
  131.     mOKButton = (LPushButton*) FindPaneByID ('OK  ');
  132.  
  133.  
  134.     UReanimator::LinkListenerToControls(this, this, RidL_ModalButtonsID);
  135.         // the purpose is to "connect" self to whatever controls
  136.         // that we want to "listen" to
  137.  
  138. // any additional initialization for your dialog:
  139.  
  140. }
  141.  
  142. //----------
  143. void    CModalButtons::DataChanged (
  144.     long        inDataID)
  145. {
  146.     StopListening ();
  147.  
  148.  
  149.     StartListening ();
  150. }
  151.  
  152. //----------
  153. void    CModalButtons::ListenToMessage (
  154.     MessageT    inMessage,
  155.     void        *ioParam)
  156. {
  157.     switch (inMessage) {
  158.     case msg_OK:
  159.             GetSuperCommander()->ProcessCommand(-mCommand, this);
  160.         break;
  161.  
  162.     case msg_Cancel:
  163.             DoClose();
  164.         break;
  165.  
  166.  
  167.     default:
  168.           ; // do something
  169.         break;
  170.     }
  171. }
  172.  
  173. //----------
  174. Boolean        CModalButtons::ObeyCommand (
  175.     CommandT    inCommand,
  176.     void*        ioParam)
  177. {
  178.     Boolean        cmdHandled = true;
  179.  
  180.     if (inCommand < 0) {
  181.         // modal dialog has finished
  182.  
  183.         switch (-inCommand) {
  184.         }
  185.  
  186.     } else {
  187.         switch (inCommand) {
  188.  
  189.         default:
  190.                 cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
  191.             break;
  192.         }
  193.     }
  194.  
  195.     return cmdHandled;
  196. }
  197.  
  198. //----------
  199. void    CModalButtons::FindCommandStatus (
  200.     CommandT    inCommand,
  201.     Boolean        &outEnabled,
  202.     Boolean        &outUsesMark,
  203.     Char16        &outMark,
  204.     Str255        outName)
  205. {
  206.     outUsesMark = false;
  207.  
  208.     switch (inCommand) {
  209.  
  210.     // +++ Add cases here for the commands you handle
  211.  
  212.     default:
  213.             LGADialog::FindCommandStatus(inCommand, outEnabled,
  214.                                             outUsesMark, outMark, outName);
  215.         break;
  216.     }
  217. }
  218.  
  219. // following functions will be obsoleted
  220. // retained only for backwards compatibility
  221.